/**
 * 系统信息工具类
 */

// 获取系统信息，计算状态栏和导航栏高度

// 获取系统信息
const systemInfo = wx.getSystemInfoSync();
// 获取胶囊按钮位置信息
const menuButtonInfo = wx.getMenuButtonBoundingClientRect();

// 状态栏高度
const statusBarHeight = systemInfo.statusBarHeight;

// 胶囊按钮与状态栏的间距（胶囊上边距）
const menuButtonPaddingTop = menuButtonInfo.top - statusBarHeight;

// 导航栏高度 = 胶囊高度 + 胶囊上下边距(相等) * 2
const navBarHeight = menuButtonInfo.height + menuButtonPaddingTop * 2;

// 导航栏和状态栏总高度
const headerHeight = statusBarHeight + navBarHeight;

// 胶囊实际位置，用于定位导航栏标题
const menuButtonLeft = menuButtonInfo.left;
const menuButtonTop = menuButtonInfo.top;
const menuButtonWidth = menuButtonInfo.width;

// 计算左侧按钮与胶囊的距离，保持两边平衡
const leftPadding = menuButtonLeft - 10;

// 获取屏幕安全区域
const safeArea = systemInfo.safeArea;
// 底部安全区域高度(主要针对iPhone X以上机型)
const bottomSafeHeight = systemInfo.screenHeight - safeArea.bottom;

// 导出系统信息
module.exports = {
  statusBarHeight,
  navBarHeight,
  headerHeight,
  menuButtonPaddingTop,
  menuButtonLeft,
  menuButtonTop,
  menuButtonHeight: 32,
  menuButtonWidth,
  leftPadding,
  bottomSafeHeight,
  screenWidth: systemInfo.screenWidth,
  screenHeight: systemInfo.screenHeight,
  windowWidth: systemInfo.windowWidth,
  windowHeight: systemInfo.windowHeight,
  pixelRatio: systemInfo.pixelRatio,
  safeArea
}; 